--情绪吸收
local qingxuxishou = fk.CreateSkill {
    name = "mcdh_qingxuxishou"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

qingxuxishou:addEffect(fk.CardUsing,{
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(self) and player.phase == Player.NotActive and player:usedSkillTimes(self.name, Player.HistoryTurn)==0 and data.card.suit ~= Card.NoSuit
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local current = room.current
        if current:isAlive() and player:isAlive() then
            local cards = current.player_cards[Player.Hand]
            local suitcard=table.filter(cards, function (id) return Fk:getCardById(id).suit == data.card.suit end)
            local ids, choice = U.askforChooseCardsAndChoice(player, suitcard, {"mcdh_qxxs_getcard"}, self.name, "#mcdh_qxxs-view::" .. current.id, {"Cancel"}, 1, 1, cards)
            if choice == "mcdh_qxxs_getcard" then
                room:obtainCard(player, ids, true, fk.ReasonPrey, player.id, self.name)
                current:drawCards(1, self.name)
            end
        end
    end
})

qingxuxishou:addEffect(fk.CardResponding,{
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(self) and player.phase == Player.NotActive and player:usedSkillTimes(self.name, Player.HistoryTurn)==0 and data.card.suit ~= Card.NoSuit
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local current = room.current
        if current:isAlive() and player:isAlive() then
            local cards = current.player_cards[Player.Hand]
            local suitcard=table.filter(cards, function (id) return Fk:getCardById(id).suit == data.card.suit end)
            local ids, choice = U.askforChooseCardsAndChoice(player, suitcard, {"mcdh_qxxs_getcard"}, self.name, "#mcdh_qxxs-view::" .. current.id, {"Cancel"}, 1, 1, cards)
            if choice == "mcdh_qxxs_getcard" then
                room:obtainCard(player, ids, true, fk.ReasonPrey, player.id, self.name)
                current:drawCards(1, self.name)
            end
        end
    end
})


Fk:loadTranslationTable {
    ["mcdh_qingxuxishou"] = "情绪吸收",
    [":mcdh_qingxuxishou"] = "每回合限一次，当你于回合外使用或打出牌时，你可以观看当前回合角色的手牌，然后你可以展示并获得其中一张与你使用或打出的牌花色相同的牌，若如此做，其摸一张牌",
    ["mcdh_qxxs_getcard"] = "获得此牌并令来源摸一张牌",
    ["#mcdh_qxxs-view"] = "情绪吸收：观看%dest的手牌"
}


return qingxuxishou